import { ModalForm } from '@ant-design/pro-components';
import type { FormInstance } from 'antd';
import { Collapse, Checkbox, message } from 'antd';
import { useRef } from 'react';
import CollapsePanel from 'antd/lib/collapse/CollapsePanel';
import { useModel } from 'umi';
import type { CheckboxChangeEvent } from 'antd/lib/checkbox';
import styles from '../style.less';
import { CaretRightFilled } from '@ant-design/icons';
import { getAuthById, updateAuthById } from '../service';
import { Auths } from '@/utils/types.d';
import type { AuthType } from '../types.d';
import { EMPTYAUTH } from '../types.d';
import { useAuthVariable } from '../hooks/useAuthVariable';

interface AuthSettingProps {
  authId: string;
  ownerName: string;
}

const CheckboxGroup = Checkbox.Group;

export default (props: AuthSettingProps) => {
  const { initialState } = useModel('@@initialState');
  const currUser = initialState?.currentUser;
  const CURRAUTH: AuthType = currUser?.auth || EMPTYAUTH;
  // TODO: 扩展权限

  const OPER_SYSTEMUSER = CURRAUTH.systemUser || [];
  const OPER_SYSRECORD = CURRAUTH.sysRecord || [];
  const OPER_SENSORDEVICE = CURRAUTH.sensorDevice || [];
  const OPER_PATROLDEVICE = CURRAUTH.patrolDevice || [];
  const OPER_PARKINGLOT = CURRAUTH.parkinglot || [];
  const OPER_PARKINGSPOT = CURRAUTH.parkingspot || [];
  const OPER_BATCHTASK = CURRAUTH.batchTask || [];
  const OPER_CHARGERULE = CURRAUTH.chargeRule || [];
  const OPER_PARKINGRECORD = CURRAUTH.parkingRecord || [];
  const OPER_PARKINGORDER = CURRAUTH.parkingOrder || [];
  const OPER_TOLLCOLLECTOR = CURRAUTH.tollCollector || [];
  const OPER_MEMBER = CURRAUTH.member || [];
  const OPER_WECHATUSER = CURRAUTH.wechatUser || [];
  const OPER_ARREARSRECOVERY = CURRAUTH.arrearsRecovery || [];
  const OPER_REVENUE = CURRAUTH.revenue || [];
  const OPER_FAILUREREPORT = CURRAUTH.failureReport || [];
  const OPER_WEBAPPUSER = CURRAUTH.webAppUser || [];
  // const OPER_INVOICE = CURRAUTH.invoice || [];
  const OPER_ABNORMALAPPEAL = CURRAUTH.abnormalAppeal || [];
  const OPER_SCHEDULEMANAGEMENT = CURRAUTH.scheduleManagement || [];
  // TODO: 异常订单权限添加
  const OPER_PACKAGEMANAGER = CURRAUTH.packageManager || [];
  const OPER_PADCONFIG = CURRAUTH.systemConfig || [];
  const OPER_EXCEPTION_ORDER = CURRAUTH.abnormalOrder || [];

  const { authId, ownerName } = props;
  const systemSettingRef = useRef<FormInstance>();
  // systemUser
  const systemUser = useAuthVariable(OPER_SYSTEMUSER);
  // tollCollector
  const tollCollector = useAuthVariable(OPER_TOLLCOLLECTOR);
  // sysRecord
  const sysRecord = useAuthVariable(OPER_SYSRECORD);
  // sensor
  const sensorDevice = useAuthVariable(OPER_SENSORDEVICE);
  // patrol
  const patrolDevice = useAuthVariable(OPER_PATROLDEVICE);
  // parkinglot
  const parkinglot = useAuthVariable(OPER_PARKINGLOT);
  // parkingspot
  const parkingspot = useAuthVariable(OPER_PARKINGSPOT);
  // batchTask
  const batchTask = useAuthVariable(OPER_BATCHTASK);
  // chargeRule
  const chargeRule = useAuthVariable(OPER_CHARGERULE);
  // parkingRecord
  const parkingRecord = useAuthVariable(OPER_PARKINGRECORD);
  // parkingOrder
  const parkingOrder = useAuthVariable(OPER_PARKINGORDER);
  // member
  const member = useAuthVariable(OPER_MEMBER);
  // wechatUser
  const wechatUser = useAuthVariable(OPER_WECHATUSER);
  //arrearsRecovery
  const arrearsRecovery = useAuthVariable(OPER_ARREARSRECOVERY);
  // revenue
  const revenue = useAuthVariable(OPER_REVENUE);
  // failureReport
  const failureReport = useAuthVariable(OPER_FAILUREREPORT);
  // webAppUser
  const webAppUser = useAuthVariable(OPER_WEBAPPUSER);
  // invoice
  // const invoice = useAuthVariable(OPER_INVOICE);
  //abnormalAppeal
  const abnormalAppeal = useAuthVariable(OPER_ABNORMALAPPEAL);
  // scheduleManagement
  const scheduleManagement = useAuthVariable(OPER_SCHEDULEMANAGEMENT);
  // packageManager
  const packageManager = useAuthVariable(OPER_PACKAGEMANAGER);
  // systemConfig
  const systemConfig = useAuthVariable(OPER_PADCONFIG);
  // abnormalOrder
  const abnormalOrder = useAuthVariable(OPER_EXCEPTION_ORDER);

  const onChange = (list: any[], authVariable: AuthVariable) => {
    let tempList = list;
    if (!list.includes(Auths.READ)) {
      message.warn({ content: '无法在无 [查看] 权限时，操作模块', key: 'read_error' });
      authVariable.setEnable(true);
      tempList = [];
    } else {
      authVariable.setEnable(false);
    }
    authVariable.setList(tempList);
    authVariable.setIntermin(!!tempList.length && tempList.length < authVariable.auth.length);
    authVariable.setCheckAll(tempList.length === authVariable.auth.length);
  };

  const onCheckAllChange = (e: CheckboxChangeEvent, authVariable: AuthVariable) => {
    authVariable.setList(
      e.target.checked ? authVariable.auth.map((item: { value: any }) => item.value) : [],
    );
    authVariable.setIntermin(false);
    authVariable.setEnable(!e.target.checked);
    authVariable.setCheckAll(e.target.checked);
  };

  const simplyInit = (authVariable: AuthVariable, dataList: Auths[] = []) => {
    if (dataList.length === 0) {
      authVariable.setIntermin(false);
      authVariable.setEnable(true);
    } else if (dataList.length === authVariable.auth.length) {
      authVariable.setIntermin(false);
      authVariable.setCheckAll(true);
    }
  };

  return (
    <ModalForm
      formRef={systemSettingRef}
      width={700}
      modalProps={{
        destroyOnClose: true,
      }}
      title={
        <div>
          权限配置<small style={{ color: '#bbb' }}>（{ownerName}）</small>
        </div>
      }
      trigger={
        <a
          onClick={async () => {
            const { data } = await getAuthById(authId);
            sensorDevice.setList(data.sensorDevice);
            patrolDevice.setList(data.patrolDevice);
            systemUser.setList(data.systemUser);
            sysRecord.setList(data.sysRecord);
            parkinglot.setList(data.parkinglot);
            parkingspot.setList(data.parkingspot);
            batchTask.setList(data.batchTask);
            chargeRule.setList(data.chargeRule);
            parkingRecord.setList(data.parkingRecord);
            parkingOrder.setList(data.parkingOrder);
            tollCollector.setList(data.tollCollector);
            member.setList(data.member);
            wechatUser.setList(data.wechatUser);
            arrearsRecovery.setList(data.arrearsRecovery);
            revenue.setList(data.revenue);
            failureReport.setList(data.failureReport);
            webAppUser.setList(data.webAppUser);
            // invoice.setList(data.invoice);
            abnormalAppeal.setList(data.abnormalAppeal);
            scheduleManagement.setList(data.scheduleManagement);
            packageManager.setList(data.packageManager);
            systemConfig.setList(data.systemConfig);
            abnormalOrder.setList(data.abnormalOrder);
            // 用户
            simplyInit(systemUser, data.systemUser);
            // 收费人员
            simplyInit(tollCollector, data.tollCollector);
            // 系统日志
            simplyInit(sysRecord, data.sysRecord);
            // 地磁设备
            simplyInit(sensorDevice, data.sensorDevice);
            // 巡检设备
            simplyInit(patrolDevice, data.patrolDevice);
            // 路段
            simplyInit(parkinglot, data.parkinglot);
            // 泊位
            simplyInit(parkingspot, data.parkingspot);
            // 批量任务
            simplyInit(batchTask, data.batchTask);
            // 收费规则
            simplyInit(chargeRule, data.chargeRule);
            // 停车记录
            simplyInit(parkingRecord, data.parkingRecord);
            // 停车订单
            simplyInit(parkingOrder, data.parkingOrder);
            // 会员卡
            simplyInit(member, data.member);
            // 微信小程序
            simplyInit(wechatUser, data.wechatUser);
            // 欠费追缴
            simplyInit(arrearsRecovery, data.arrearsRecovery);
            // 营收统计
            simplyInit(revenue, data.revenue);
            // 故障上报
            simplyInit(failureReport, data.failureReport);
            // h5用户
            simplyInit(webAppUser, data.webAppUser);
            // 发票
            // simplyInit(invoice, data.invoice);
            // 异常申诉
            simplyInit(abnormalAppeal, data.abnormalAppeal);
            // 排班管理
            simplyInit(scheduleManagement, data.scheduleManagement);
            // 包管理
            simplyInit(packageManager, data.packageManager);
            // PDA配置
            simplyInit(systemConfig, data.systemConfig);
            // 异常订单
            simplyInit(abnormalOrder, data.abnormalOrder);
          }}
        >
          权限配置
        </a>
      }
      onFinish={async () => {
        const res = await updateAuthById(authId, {
          systemUser: systemUser.list,
          sysRecord: sysRecord.list,
          sensorDevice: sensorDevice.list,
          patrolDevice: patrolDevice.list,
          parkinglot: parkinglot.list,
          parkingspot: parkingspot.list,
          batchTask: batchTask.list,
          chargeRule: chargeRule.list,
          parkingRecord: parkingRecord.list,
          parkingOrder: parkingOrder.list,
          tollCollector: tollCollector.list,
          member: member.list,
          wechatUser: wechatUser.list,
          arrearsRecovery: arrearsRecovery.list,
          revenue: revenue.list,
          failureReport: failureReport.list,
          webAppUser: webAppUser.list,
          // invoice: invoice.list,
          abnormalAppeal: abnormalAppeal.list,
          scheduleManagement: scheduleManagement.list,
          packageManager: packageManager.list,
          systemConfig: systemConfig.list,
          abnormalOrder: abnormalOrder.list,
        });
        if (res.success) {
          message.success({ content: res.message, key: 'auth_msg' });
          return true;
        }
        message.error({ content: res.message, key: 'auth_msg' });
        return false;
      }}
    >
      <Collapse
        bordered={false}
        className={styles.mycollapse}
        expandIcon={({ isActive }) => <CaretRightFilled rotate={isActive ? 90 : 0} />}
        defaultActiveKey={[]}
        accordion
      >
        {(OPER_PARKINGLOT.length ||
          OPER_PARKINGSPOT.length ||
          OPER_PARKINGRECORD.length ||
          OPER_FAILUREREPORT.length) && (
          <CollapsePanel header="停车管理" className={styles.mypanel} key="parkingConfig">
            <Collapse accordion bordered={false} ghost defaultActiveKey={[]}>
              {OPER_PARKINGLOT.length && (
                <CollapsePanel
                  key="parkinglot"
                  header={
                    <Checkbox
                      indeterminate={parkinglot.intermin}
                      onChange={(e) => {
                        onCheckAllChange(e, parkinglot);
                      }}
                      checked={parkinglot.checkAll}
                      onClick={(e) => e.stopPropagation()}
                    >
                      路段管理
                    </Checkbox>
                  }
                >
                  <CheckboxGroup
                    options={parkinglot.auth}
                    name="parkinglot"
                    value={parkinglot.list}
                    onChange={(list) => {
                      onChange(list, parkinglot);
                    }}
                  />
                </CollapsePanel>
              )}
              {OPER_PARKINGSPOT.length && (
                <CollapsePanel
                  key="parkingspot"
                  header={
                    <Checkbox
                      indeterminate={parkingspot.intermin}
                      onChange={(e) => {
                        onCheckAllChange(e, parkingspot);
                      }}
                      checked={parkingspot.checkAll}
                      onClick={(e) => e.stopPropagation()}
                    >
                      泊位管理
                    </Checkbox>
                  }
                >
                  <CheckboxGroup
                    options={parkingspot.auth}
                    name="parkingspot"
                    value={parkingspot.list}
                    onChange={(list) => {
                      onChange(list, parkingspot);
                    }}
                  />
                </CollapsePanel>
              )}
              {OPER_PARKINGRECORD.length && (
                <CollapsePanel
                  key="parkingRecord"
                  header={
                    <Checkbox
                      indeterminate={parkingRecord.intermin}
                      onChange={(e) => {
                        onCheckAllChange(e, parkingRecord);
                      }}
                      checked={parkingRecord.checkAll}
                      onClick={(e) => e.stopPropagation()}
                    >
                      停车记录
                    </Checkbox>
                  }
                >
                  <CheckboxGroup
                    options={parkingRecord.auth}
                    name="parkingRecord"
                    value={parkingRecord.list}
                    onChange={(list) => {
                      onChange(list, parkingRecord);
                    }}
                  />
                </CollapsePanel>
              )}
              {OPER_FAILUREREPORT.length && (
                <CollapsePanel
                  key="failureReport"
                  header={
                    <Checkbox
                      indeterminate={failureReport.intermin}
                      onChange={(e) => {
                        onCheckAllChange(e, failureReport);
                      }}
                      checked={failureReport.checkAll}
                      onClick={(e) => e.stopPropagation()}
                    >
                      故障上报
                    </Checkbox>
                  }
                >
                  <CheckboxGroup
                    options={failureReport.auth}
                    name="failureReport"
                    value={failureReport.list}
                    onChange={(list) => {
                      onChange(list, failureReport);
                    }}
                  />
                </CollapsePanel>
              )}
            </Collapse>
          </CollapsePanel>
        )}
        {(OPER_SENSORDEVICE.length || OPER_PATROLDEVICE.length) && (
          <CollapsePanel header="设备管理" className={styles.mypanel} key="deviceConfig">
            <Collapse accordion bordered={false} ghost defaultActiveKey={[]}>
              {OPER_SENSORDEVICE.length && (
                <CollapsePanel
                  key="sensorDevice"
                  header={
                    <Checkbox
                      indeterminate={sensorDevice.intermin}
                      onChange={(e) => {
                        onCheckAllChange(e, sensorDevice);
                      }}
                      checked={sensorDevice.checkAll}
                      onClick={(e) => e.stopPropagation()}
                    >
                      地磁设备
                    </Checkbox>
                  }
                >
                  <CheckboxGroup
                    options={sensorDevice.auth}
                    name="sensorDevice"
                    value={sensorDevice.list}
                    onChange={(list) => {
                      onChange(list, sensorDevice);
                    }}
                  />
                </CollapsePanel>
              )}
              {OPER_PATROLDEVICE.length && (
                <CollapsePanel
                  key="patrolDevice"
                  header={
                    <Checkbox
                      indeterminate={patrolDevice.intermin}
                      onChange={(e) => {
                        onCheckAllChange(e, patrolDevice);
                      }}
                      checked={patrolDevice.checkAll}
                      onClick={(e) => e.stopPropagation()}
                    >
                      巡检设备
                    </Checkbox>
                  }
                >
                  <CheckboxGroup
                    options={patrolDevice.auth}
                    name="patrolDevice"
                    value={patrolDevice.list}
                    onChange={(list) => {
                      onChange(list, patrolDevice);
                    }}
                  />
                </CollapsePanel>
              )}
            </Collapse>
          </CollapsePanel>
        )}
        {OPER_REVENUE.length && (
          <CollapsePanel
            className={styles.mypanel}
            header={
              <Checkbox
                indeterminate={revenue.intermin}
                onChange={(e) => {
                  onCheckAllChange(e, revenue);
                }}
                checked={revenue.checkAll}
                onClick={(e) => e.stopPropagation()}
              >
                营收统计
              </Checkbox>
            }
            key="revenue"
          >
            <CheckboxGroup
              options={revenue.auth}
              name="revenue"
              value={revenue.list}
              onChange={(list) => {
                onChange(list, revenue);
              }}
            />
          </CollapsePanel>
        )}
        {OPER_CHARGERULE.length && (
          <CollapsePanel
            className={styles.mypanel}
            header={
              <Checkbox
                indeterminate={chargeRule.intermin}
                onChange={(e) => {
                  onCheckAllChange(e, chargeRule);
                }}
                checked={chargeRule.checkAll}
                onClick={(e) => e.stopPropagation()}
              >
                收费规则
              </Checkbox>
            }
            key="chargeRule"
          >
            <CheckboxGroup
              options={chargeRule.auth}
              name="chargeRule"
              value={chargeRule.list}
              onChange={(list) => {
                onChange(list, chargeRule);
              }}
            />
          </CollapsePanel>
        )}
        {(OPER_PARKINGORDER.length || OPER_EXCEPTION_ORDER.length) && (
          <CollapsePanel header="订单管理" className={styles.mypanel} key="orderConfig">
            <Collapse accordion bordered={false} ghost defaultActiveKey={[]}>
              {OPER_PARKINGORDER.length && (
                <CollapsePanel
                  key="parkingOrder"
                  header={
                    <Checkbox
                      indeterminate={parkingOrder.intermin}
                      onChange={(e) => {
                        onCheckAllChange(e, parkingOrder);
                      }}
                      checked={parkingOrder.checkAll}
                      onClick={(e) => e.stopPropagation()}
                    >
                      停车订单
                    </Checkbox>
                  }
                >
                  <CheckboxGroup
                    options={parkingOrder.auth}
                    name="parkingOrder"
                    value={parkingOrder.list}
                    onChange={(list) => {
                      onChange(list, parkingOrder);
                    }}
                  />
                </CollapsePanel>
              )}
              {OPER_EXCEPTION_ORDER.length && (
                <CollapsePanel
                  key="abnormalOrder"
                  header={
                    <Checkbox
                      indeterminate={abnormalOrder.intermin}
                      onChange={(e) => {
                        onCheckAllChange(e, abnormalOrder);
                      }}
                      checked={abnormalOrder.checkAll}
                      onClick={(e) => e.stopPropagation()}
                    >
                      异常订单
                    </Checkbox>
                  }
                >
                  <CheckboxGroup
                    options={abnormalOrder.auth}
                    name="abnormalOrder"
                    value={abnormalOrder.list}
                    onChange={(list) => {
                      onChange(list, abnormalOrder);
                    }}
                  />
                </CollapsePanel>
              )}
            </Collapse>
          </CollapsePanel>
        )}
        {(OPER_TOLLCOLLECTOR.length || OPER_SCHEDULEMANAGEMENT.length) && (
          <CollapsePanel header="员工管理" className={styles.mypanel} key="staffConfig">
            <Collapse accordion bordered={false} ghost defaultActiveKey={[]}>
              {OPER_TOLLCOLLECTOR.length && (
                <CollapsePanel
                  header={
                    <Checkbox
                      indeterminate={tollCollector.intermin}
                      onChange={(e) => {
                        onCheckAllChange(e, tollCollector);
                      }}
                      checked={tollCollector.checkAll}
                      onClick={(e) => e.stopPropagation()}
                    >
                      收费人员
                    </Checkbox>
                  }
                  key="tollCollector"
                >
                  <CheckboxGroup
                    options={tollCollector.auth}
                    name="tollCollector"
                    value={tollCollector.list}
                    onChange={(list) => {
                      onChange(list, tollCollector);
                    }}
                  />
                </CollapsePanel>
              )}
              {OPER_SCHEDULEMANAGEMENT.length && (
                <CollapsePanel
                  key="scheduleManagement"
                  header={
                    <Checkbox
                      indeterminate={scheduleManagement.intermin}
                      onChange={(e) => {
                        onCheckAllChange(e, scheduleManagement);
                      }}
                      checked={scheduleManagement.checkAll}
                      onClick={(e) => e.stopPropagation()}
                    >
                      排班管理
                    </Checkbox>
                  }
                >
                  <CheckboxGroup
                    options={scheduleManagement.auth}
                    name="scheduleManagement"
                    value={scheduleManagement.list}
                    onChange={(list) => {
                      onChange(list, scheduleManagement);
                    }}
                  />
                </CollapsePanel>
              )}
            </Collapse>
          </CollapsePanel>
        )}

        {OPER_ARREARSRECOVERY.length && (
          <CollapsePanel
            key="arrearsRecovery"
            className={styles.mypanel}
            header={
              <Checkbox
                indeterminate={arrearsRecovery.intermin}
                onChange={(e) => {
                  onCheckAllChange(e, arrearsRecovery);
                }}
                checked={arrearsRecovery.checkAll}
                onClick={(e) => e.stopPropagation()}
              >
                欠费追缴
              </Checkbox>
            }
          >
            <CheckboxGroup
              options={arrearsRecovery.auth}
              name="arrearsRecovery"
              value={arrearsRecovery.list}
              onChange={(list) => {
                onChange(list, arrearsRecovery);
              }}
            />
          </CollapsePanel>
        )}
        {OPER_MEMBER.length && (
          <CollapsePanel
            className={styles.mypanel}
            header={
              <Checkbox
                indeterminate={member.intermin}
                onChange={(e) => {
                  onCheckAllChange(e, member);
                }}
                checked={member.checkAll}
                onClick={(e) => e.stopPropagation()}
              >
                会员卡模块
              </Checkbox>
            }
            key="member"
          >
            <CheckboxGroup
              options={member.auth}
              name="member"
              value={member.list}
              onChange={(list) => {
                onChange(list, member);
              }}
            />
          </CollapsePanel>
        )}
        {OPER_WECHATUSER.length && (
          <CollapsePanel
            className={styles.mypanel}
            header={
              <Checkbox
                indeterminate={wechatUser.intermin}
                onChange={(e) => {
                  onCheckAllChange(e, wechatUser);
                }}
                checked={wechatUser.checkAll}
                onClick={(e) => e.stopPropagation()}
              >
                微信用户
              </Checkbox>
            }
            key="wechatUser"
          >
            <CheckboxGroup
              options={wechatUser.auth}
              name="wechatUser"
              value={wechatUser.list}
              onChange={(list) => {
                onChange(list, wechatUser);
              }}
            />
          </CollapsePanel>
        )}
        {OPER_WEBAPPUSER.length && (
          <CollapsePanel
            className={styles.mypanel}
            header={
              <Checkbox
                indeterminate={webAppUser.intermin}
                onChange={(e) => {
                  onCheckAllChange(e, webAppUser);
                }}
                checked={webAppUser.checkAll}
                onClick={(e) => e.stopPropagation()}
              >
                H5用户
              </Checkbox>
            }
            key="webAppUser"
          >
            <CheckboxGroup
              options={webAppUser.auth}
              name="webAppUser"
              value={webAppUser.list}
              onChange={(list) => {
                onChange(list, webAppUser);
              }}
            />
          </CollapsePanel>
        )}
        {/* {OPER_INVOICE.length && (
          <CollapsePanel
            className={styles.mypanel}
            header={
              <Checkbox
                indeterminate={invoice.intermin}
                onChange={(e) => {
                  onCheckAllChange(e, invoice);
                }}
                checked={invoice.checkAll}
                onClick={(e) => e.stopPropagation()}
              >
                发票管理
              </Checkbox>
            }
            key="invoice"
          >
            <CheckboxGroup
              options={invoice.auth}
              name="invoice"
              value={invoice.list}
              onChange={(list) => {
                onChange(list, invoice);
              }}
            />
          </CollapsePanel>
        )} */}
        {OPER_PACKAGEMANAGER.length && (
          <CollapsePanel
            className={styles.mypanel}
            header={
              <Checkbox
                indeterminate={packageManager.intermin}
                onChange={(e) => {
                  onCheckAllChange(e, packageManager);
                }}
                checked={packageManager.checkAll}
                onClick={(e) => e.stopPropagation()}
              >
                包管理
              </Checkbox>
            }
            key="packageManager"
          >
            <CheckboxGroup
              options={packageManager.auth}
              name="packageManager"
              value={packageManager.list}
              onChange={(list) => {
                onChange(list, packageManager);
              }}
            />
          </CollapsePanel>
        )}
        {OPER_ABNORMALAPPEAL.length && (
          <CollapsePanel
            className={styles.mypanel}
            header={
              <Checkbox
                indeterminate={abnormalAppeal.intermin}
                onChange={(e) => {
                  onCheckAllChange(e, abnormalAppeal);
                }}
                checked={abnormalAppeal.checkAll}
                onClick={(e) => e.stopPropagation()}
              >
                异常申诉
              </Checkbox>
            }
            key="abnormalAppeal"
          >
            <CheckboxGroup
              options={abnormalAppeal.auth}
              name="abnormalAppeal"
              value={abnormalAppeal.list}
              onChange={(list) => {
                onChange(list, abnormalAppeal);
              }}
            />
          </CollapsePanel>
        )}
        {OPER_BATCHTASK.length && (
          <CollapsePanel
            className={styles.mypanel}
            header={
              <Checkbox
                indeterminate={batchTask.intermin}
                onChange={(e) => {
                  onCheckAllChange(e, batchTask);
                }}
                checked={batchTask.checkAll}
                onClick={(e) => e.stopPropagation()}
              >
                批量任务
              </Checkbox>
            }
            key="batchTask"
          >
            <CheckboxGroup
              options={batchTask.auth}
              name="batchTask"
              value={batchTask.list}
              onChange={(list) => {
                onChange(list, batchTask);
              }}
            />
          </CollapsePanel>
        )}
        {OPER_SYSTEMUSER.length && (
          <CollapsePanel
            className={styles.mypanel}
            header={
              <Checkbox
                indeterminate={systemUser.intermin}
                onChange={(e) => {
                  onCheckAllChange(e, systemUser);
                }}
                checked={systemUser.checkAll}
                onClick={(e) => e.stopPropagation()}
              >
                用户模块
              </Checkbox>
            }
            key="systemUser"
          >
            <CheckboxGroup
              options={systemUser.auth}
              name="systemUser"
              value={systemUser.list}
              onChange={(list) => {
                onChange(list, systemUser);
              }}
            />
          </CollapsePanel>
        )}
        {OPER_PADCONFIG.length && (
          <CollapsePanel
            className={styles.mypanel}
            header={
              <Checkbox
                indeterminate={systemConfig.intermin}
                onChange={(e) => {
                  onCheckAllChange(e, systemConfig);
                }}
                checked={systemConfig.checkAll}
                onClick={(e) => e.stopPropagation()}
              >
                PDA配置
              </Checkbox>
            }
            key="systemConfig"
          >
            <CheckboxGroup
              options={systemConfig.auth}
              name="systemConfig"
              value={systemConfig.list}
              onChange={(list) => {
                onChange(list, systemConfig);
              }}
            />
          </CollapsePanel>
        )}
        {OPER_SYSRECORD.length && (
          <CollapsePanel
            className={styles.mypanel}
            header={
              <Checkbox
                indeterminate={sysRecord.intermin}
                onChange={(e) => {
                  onCheckAllChange(e, sysRecord);
                }}
                checked={sysRecord.checkAll}
                onClick={(e) => e.stopPropagation()}
              >
                系统日志
              </Checkbox>
            }
            key="sysRecord"
          >
            <CheckboxGroup
              options={sysRecord.auth}
              name="sysRecord"
              value={sysRecord.list}
              onChange={(list) => {
                onChange(list, sysRecord);
              }}
            />
          </CollapsePanel>
        )}
      </Collapse>
    </ModalForm>
  );
};
